package com.gongzhiyun.springboot3test.mapper.novel;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gongzhiyun.springboot3test.entity.novel.NovelChapter;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NovelChapterMapper extends BaseMapper<NovelChapter> {
    //获取某部小说的总章节数
    @Select("select count(*) from novel_chapter where novel_id=#{id}")
    Integer getChapterCount(Integer id);

    //根据章节序号获取章节内容
    @Select("select * from novel_chapter where chapter_order=#{id} and novel_id=#{novelId}")
    NovelChapter getChapterContent(Integer id,Integer novelId);

    //查询某部小说的章节列表
    @Select("select  novel_id,chapter_order,chapter_title from novel_chapter where novel_id=#{novelId} order by chapter_order")
    List<NovelChapter> queryChapter(Integer novelId);

    //根据小说标题查询小说内容
    @Select("select  * from novel_chapter where chapter_title=#{title}")
    NovelChapter queryChapterByTitle(String title);
}
